package org.yanex.project.api.items;

import org.yanex.project.api.parsers.Field;
import org.yanex.project.api.parsers.ParsedItem;

import android.view.View;
import android.widget.TextView;

public class Category extends SelfItem {
	private static final long serialVersionUID = -5126268573510120410L;

	private long id;
	private String name;

	public Category(ParsedItem item) {
		setId(item.get(Field.ID, 0l));
		setName(item.get(Field.NAME, ""));
	}

	public Category(long id, String name) {
		this.id = id;
		this.name = name;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Override
	public String toString() {
		return "Category: [id="+id+"; name=\""+name+"\"]";
	}

	@Override
	public int getLayoutId() {
		return android.R.layout.simple_list_item_1;
	}

	@Override
	public void setup(SelfItemAdapter adapter, View convertView, int position) {
		TextView t = (TextView)convertView.findViewById(android.R.id.text1);
		
		t.setText(name);
	}
	
}
